
$(function () {

    $.validator.setDefaults({
        submitHandler: function () {
            let md5 = hex_md5(myForm.password.value) // 加密
            myForm.password.value = md5;
            myForm.submit(); // js 表单提交
            $(".submitBtn").attr("disabled", true);
        }
    });
    $('#myForm').validate({
        rules: {
            username: {
                required: true,
                email: true,
            },
            password: {
                required: true,
                minlength: 6
            },
        },
        messages: {
            username: {
                required: "请输入邮箱地址",
                email: "邮箱地址不正确"
            },
            password: {
                required: "请提供密码",
                minlength: "密码至少 6 个字符"
            },
        },
        errorElement: 'span',
        errorPlacement: function (error, element) {
            error.addClass('invalid-feedback');
            element.closest('.input-group').append(error);
        },
        highlight: function (element, errorClass, validClass) {
            $(element).addClass('is-invalid');
        },
        unhighlight: function (element, errorClass, validClass) {
            $(element).removeClass('is-invalid');
        }
    });
});